package core.Resource
{
	import core.map.MapTile;

	public class InstancePool
	{
		
		private var _pool:Array;
		
		public function InstancePool()
		{
			_pool = [];
		}
		
		public static function get instance():InstancePool
		{
			if(_instance == null)
				_instance = new InstancePool();
			return _instance;
		}
		
		public function getDressPack():DressPack
		{
			if(_pool["DressPack"] != null && _pool["DressPack"].length>0)
			{
				return (_pool["DressPack"] as Vector.<DressPack>).pop();
			}
			else
				return new DressPack();
			
		}
		
		public function setDressPack(pack:DressPack):void
		{
			pack.reset();
			if(_pool["DressPack"] == null)
				_pool["DressPack"] = new Vector.<DressPack>();
			(_pool["DressPack"] as Vector.<DressPack>).push(pack);
		}
		
		
		public function getAniPack():AniPack
		{
			if(_pool["AniPack"] != null && _pool["AniPack"].length>0)
			{
				return (_pool["AniPack"] as Vector.<AniPack>).pop();
			}
			else
				return new AniPack();
			
		}
		
		public function setAniPack(pack:AniPack):void
		{
			pack.reset();
			if(_pool["AniPack"] == null)
				_pool["AniPack"] = new Vector.<AniPack>();
			(_pool["AniPack"] as Vector.<AniPack>).push(pack);
		}
		
		public function getMapTile():MapTile
		{
			if(_pool["MapTile"] != null && _pool["MapTile"].length>0)
			{
				return (_pool["MapTile"] as Vector.<MapTile>).pop();
			}
			else
				return new MapTile();
			
		}
		
		public function setMapTile(tile:MapTile):void
		{
			tile.reset();
			if(_pool["MapTile"] == null)
				_pool["MapTile"] = new Vector.<MapTile>();
			(_pool["MapTile"] as Vector.<MapTile>).push(tile);
		}
		
		private static var _instance:InstancePool;
		
		
	}
}